﻿#ifndef __SS_MYSQL_STMT_QUERY_H__
#define __SS_MYSQL_STMT_QUERY_H__
#include "./ssMySQLConnection.h"
#include "./ssMySQLStmt.h"
#include <map>


namespace StarSeeker
{
class ssMySQLStmtQuery : public ssMySQLConnection
{
public:
	ssMySQLStmtQuery();
	~ssMySQLStmtQuery();
	//结束连接
	void StmtExit();
	//查询
	void Query(const char* pSql, const char* pIn, const char* pOut, u8 resultFlag, i32 num, ...);
	void Query(const char* pSql, const char* pIn, const char* pOut, u8 resultFlag, u32 len, const char* data);
	//开始事务
	void Transaction();
	//提交事务
	void Commit();
	//回滚事务
	void Rollback();
	//获取结果
	ssMultiLineBuffer& GetResultSet();
	ssWriteBytes& GetOneResult();
	//预处理
	void PrepareQuery(u32 id, const char* pIn, const char* pOut, const char* pSql, const u8 resultFlag);
	//自动查询
	void QueryByID(u32 id, i32 num, ...);
	void QueryByID(u32 id, u32 len, const char* data);
	//获取结果
	ssMultiLineBuffer& GetResultSet(u32 id);
	ssWriteBytes& GetOneResult(u32 id);
	//获取查询类型
	u8 GetResultFlag(u32 id);
private:
	//重新预处理
	void RePrepare();
private:
	ssMySQLStmt					m_stmt;
	std::map<u32, ssMySQLStmt>	m_stmtMap;
};

}
#endif
